package com.dingli.controller;

import com.dingli.framework.entity.Member;
import com.dingli.framework.entity.Recruit;
import com.dingli.framework.entity.Resume;
import com.dingli.framework.util.Encryption;
import com.dingli.framework.util.Response;
import com.dingli.service.IRecruitService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@CrossOrigin("*")
@RestController
@RequestMapping("/relist")
@Api(tags = "招聘信息")
public class RecruitController {

    @Autowired
    private IRecruitService iRecruitService;

    @GetMapping("/Relist")
    @ApiOperation("招聘信息列表查询")
    public Response<PageInfo<Recruit>> Rtlist(@ApiParam("查询条件")
                                             @RequestParam(required = false) String search,
                                              @ApiParam("页码") @RequestParam(required = false) Integer pageNum,
                                              @ApiParam("页面大小")
                                             @RequestParam(required = false) Integer pageSize) {
        return iRecruitService.Rtlist(search, pageNum, pageSize);
    }

    @RequestMapping ("/RtselectArea")
    @CrossOrigin
    @ApiOperation("招聘信息多条件模糊查询")
    public Response<List<Recruit>> RtselectArea(@ApiParam("地区,职位,企业") @RequestParam String rtPoaition){
        return iRecruitService.RtselectArea(rtPoaition);
    }

    @PostMapping("/Rtinsert")
    @ApiOperation("招聘信息新增")
    public Object Rtinsert(@ApiParam("招聘信息") @RequestBody Recruit recruit) {
        return iRecruitService.Rtinsert(recruit);
    }

    @GetMapping("/RtselectById")
    @ApiOperation("招聘信息详情查看")
    public Response<Recruit> RtselectById(@ApiParam("招聘信息ID") @RequestParam Long rtID) {
        return iRecruitService.RtselectById(rtID);
    }

    @PostMapping("/RtupdateById")
    @ApiOperation("招聘信息修改")
    public Response<Object> RtupdateById(@ApiParam("修改的招聘信息") @RequestBody Recruit recruit) {

        return iRecruitService.RtupdateById(recruit);
    }

    @GetMapping("/RtdeleteById")
    @ApiOperation("招聘信息删除")
    public Response<Object> RtdeleteById(@ApiParam("招聘信息ID") @RequestParam Long rtID) {
        return iRecruitService.RtdeleteById(rtID);
    }

    @PostMapping("/RtupdateState")
    @ApiOperation("招聘信息审核")
    public Response<Object> RtupdateState(@ApiParam("审核招聘信息通过") @RequestBody String rtID) {
        return iRecruitService.RtupdateState(rtID);
    }

    @PostMapping("/Rtupdate")
    @ApiOperation("招聘信息审核")
    public Response<Object> Rtupdate(@ApiParam("审核招聘信息不通过") @RequestBody String rtID) {

        return iRecruitService.Rtupdate(rtID);
    }

    @RequestMapping ("/RtselectState")
    @CrossOrigin
    @ApiOperation("招聘审核查询")
    public HashMap<Object, Object> RtselectState(@ApiParam("招聘审核中查询") @RequestParam String rtState){
        Response<List<Recruit>> list = iRecruitService.RtselectState(rtState);
        HashMap<Object, Object> ob = new HashMap<>();
        ob.put("Recruit",list);
        ob.put("size",list.getData().size());
        return ob;
    }

    @RequestMapping ("/RtselectState1")
    @CrossOrigin
    @ApiOperation("招聘审核查询")
    public  HashMap<Object, Object> RtselectState1(@ApiParam("招聘审核通过查询") @RequestParam String rtState){
        Response<List<Recruit>> list = iRecruitService.RtselectState1(rtState);
        HashMap<Object, Object> yy = new HashMap<>();
        yy.put("Recruit",list);
        yy.put("size",list.getData().size());
        return yy;
    }

    @RequestMapping ("/RtAll")
    @CrossOrigin
    @ApiOperation("招聘信息统计")
    public HashMap<Object, Object> RtAll(@ApiParam("招聘信息统计") @RequestParam String rtId){
        Response<List<Recruit>> list = iRecruitService.RtAll(rtId);
        HashMap<Object, Object> yy = new HashMap<>();
//        wh.put("Member",list);
        yy.put("size",list.getData().size());
        return yy;
    }

}
